package com.zhiyun.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyun.domain.AdminNotice;
import com.zhiyun.mapper.AdminNoticeMapper;
import com.zhiyun.service.AdminNoticeService;
import com.zhiyun.util.Db;
import com.zhiyun.vo.Result;

import java.util.List;

/**
 * @author zc
 * @Date 2025/4/29 上午9:56
 */
public class AdminNoticeServiceImpl implements AdminNoticeService {
    AdminNoticeMapper adminNoticeMapper = Db.getMapper(AdminNoticeMapper.class);
    @Override
    public Result findAdminNoticeByPage(int pageNo) {
        PageHelper.startPage(pageNo, 5);
        List<AdminNotice> list = adminNoticeMapper.selectAll();
        PageInfo<AdminNotice> pageInfo = new PageInfo<>(list);
        return Result.ok(pageInfo);
    }

    @Override
    public Result addAdminNotice(AdminNotice adminNotice) {
        int rows = adminNoticeMapper.insert(adminNotice);
        if (rows > 0) {
            return Result.okMsg("发布成功");
        }
        return Result.fail("发布失败");
    }
}
